package com.nuedu.corejava.ch10;

import java.util.Deque;
import java.util.LinkedList;

public class LinkedClass {
	public static void main(String[] args) {
		// LinkedList实现了多种数据结构
		// 实现了（双端链表）结构，队列

		// 队列结构
		// 队列结构具有先进先出，后进后厨
		LinkedList<Computer> linkedList = new LinkedList<Computer>();
		
		
		//Deque<Computer> linkedlist = 
		linkedList.addLast(new Computer("HP1", 5000));
		linkedList.addLast(new Computer("HP2", 5000));
		linkedList.addLast(new Computer("HP3", 5000));
		linkedList.addLast(new Computer("HP4", 5000));
		linkedList.addLast(new Computer("HP5", 5000));
		linkedList.addLast(new Computer("HP6", 5000));
		linkedList.addLast(new Computer("HP7", 5000));
		linkedList.addLast(new Computer("HP8", 5000));

		Computer computer = null;// pollFirst取出并删除数据
		while ((computer = linkedList.pollFirst()) != null) {
			System.out.println(computer);

		}
		
		//双端队列
		linkedList.addFirst(new Computer("HP1", 5000));
		linkedList.addFirst(new Computer("HP2", 5000));
		linkedList.addFirst(new Computer("HP3", 5000));
		linkedList.addFirst(new Computer("HP4", 5000));
		linkedList.addFirst(new Computer("HP5", 5000));
		linkedList.addFirst(new Computer("HP6", 5000));
		linkedList.addFirst(new Computer("HP7", 5000));
		linkedList.addFirst(new Computer("HP8", 5000));
		/*
		 * int a = linkedList.size(); System.out.println(a);
		 */
		computer = null;// pollFirst取出并删除数据
		while ((computer = linkedList.pollFirst()) != null) {
			System.out.println(computer);

		}

	}
}